//
// Created by 吴锐 on 2022/2/28.
//

#include "iostream"

using namespace std;

template<class T1, class T2>
class Person {
public:
    T1 m_Name;
    T2 m_Age;

    Person(T1 name, T2 age) {
        this->m_Name = name;
        this->m_Age = age;
    }

    void showPerson() {
        cout << "姓名: " << this->m_Name << " 年龄: " << m_Age << endl;
    }
};

void printPerson(Person<string, int> &p) {
    p.showPerson();
}

void test01() {
    Person<string, int> p1("孙悟空", 100);
    printPerson(p1);
}

template<class T1, class T2>
void printPerson2(Person<T1, T2> &p) {
    p.showPerson();
    cout << "T1的数据类型为: " << typeid(T1).name() << endl;
    cout << "T2的数据类型为: " << typeid(T2).name() << endl;
}

void test20() {
    Person<string, int> p1("猪八戒", 90);
    printPerson2(p1);
}

template<class T>
void printPerson3(T& p){
    p.showPerson();
    cout << "T的数据类型为: " << typeid(T).name() << endl;
}

void test03(){
    Person<string, int> p("唐僧", 30);
    printPerson3(p);
}

int main() {
//    test01();
//    test20();
    test03();
    return 0;
}